//
//  TDCollectMoneyViewController.m
//  TFB
//
//  Created by Nothing on 15/3/16.
//  Copyright (c) 2015年 TD. All rights reserved.
//

#import "TDCollectMoneyViewController.h"
#import "TDLoginViewController.h"
#import "TDSwipeCardViewController.h"



@interface TDCollectMoneyViewController ()
{
}
@end

@implementation TDCollectMoneyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //self.navigationController.navigationBar.backgroundColor = [UIColor colorWithRed:31/255.0f green:121/255.0f blue:132/255.0f alpha:1.0f];
    self.navigationItem.title = @"收款";
    
    
    [self creatUI];
    
    [self testLunbotu];
    
    [self textGetinfo];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (void)testLunbotu
{

}

- (void)textGetinfo
{
    [TDHttpEngine requestForGetCustInfWithCustMobile:[[NSUserDefaults standardUserDefaults] objectForKey:CUST_MOBILE] custId:[[NSUserDefaults standardUserDefaults] objectForKey:CUST_ID] complete:^(BOOL succeed, NSString *msg, NSString *cod, TDUser *user) {
        if (succeed) {
            
        }
        else{
            [self.view makeToast:msg duration:2.0f position:@"center"];
            [self performSelector:@selector(popToLogin) withObject:self afterDelay:2.0f];
        }
    }];
}

- (void)creatUI
{
    self.moneyTF.keyboardType = UIKeyboardTypeDecimalPad;
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [self.view endEditing:YES];
}


- (IBAction)commitBtnClick:(id)sender {
    NSLog(@"%@", self.moneyTF.text);
    TDSwipeCardViewController *swipeCardVC = [[TDSwipeCardViewController alloc] init];
    swipeCardVC.hidesBottomBarWhenPushed = YES;
    swipeCardVC.payMoney = self.moneyTF.text;
    [self.navigationController pushViewController:swipeCardVC animated:YES];
    
}

- (IBAction)checkTem:(id)sender {
    [TDHttpEngine requestForGetTermListWithCustId:@"15040300000025" custMobile:@"13273901442" complete:^(BOOL succeed, NSString *msg, NSString *cod, NSArray *termArray) {
        if (succeed) {
            
        }
    }];
}

- (IBAction)checkRat:(id)sender {
    
    
}

- (IBAction)checkCustInfo:(id)sender {
    [TDHttpEngine requestForGetCustInfWithCustMobile:@"13273901442" custId:@"15040300000025" complete:^(BOOL succeed, NSString *msg, NSString *cod, TDUser *user) {
        
    }];
}

- (IBAction)getMiyao:(id)sender {

    [TDHttpEngine requestForGetMiYaoWithCustMobile:@"13273901442" termNo:@"CF0300000206" termType:@"02" custId:@"15040300000025" complete:^(BOOL succeed, NSString *msg, NSDictionary *diction) {
        if (succeed) {
            NSLog(@"%@", diction);
        }
    }];
}

- (void)popToLogin
{
    TDLoginViewController *loginVC = [[TDLoginViewController alloc] init];
    UINavigationController *loginNav = [[UINavigationController alloc] initWithRootViewController:loginVC];
    [loginNav.navigationBar setBarStyle:UIBarStyleBlack];
    UIWindow *window = [[UIApplication sharedApplication].windows objectAtIndex:0];
    window.rootViewController = loginNav;
}

@end
